package oct2013;

import java.util.HashMap;

public class TwoSum {
	public int[] twoSum(int[] numbers, int target) {
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < numbers.length; ++i) {
			map.put(numbers[i], i);
		}
		for (int i = 0; i < numbers.length; ++i) {
			Integer idx = map.get(target - numbers[i]);
			if (idx != null && idx.intValue() != i) {
				return new int[] { i + 1, idx.intValue() + 1 };
			}
		}
		return null;
	}
}
